package com.catersystem.zmy.catersystem.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.catersystem.zmy.catersystem.R;
import com.catersystem.zmy.catersystem.base.BaseActivity;
import com.catersystem.zmy.catersystem.fragment.BasicConfigurationFragment;
import com.catersystem.zmy.catersystem.fragment.HelpFragment;
import com.catersystem.zmy.catersystem.fragment.OperateFragment;
import com.catersystem.zmy.catersystem.fragment.TypeFragment;
import com.catersystem.zmy.catersystem.fragment.VoiceFragment;
import com.catersystem.zmy.catersystem.utils.SPUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 设置
 * Created by Administrator on 2017/10/30 0030.
 */

public class SettingActivity extends BaseActivity {
    @BindView(R.id.rb_operate)
    RadioButton mRbOperate;
    @BindView(R.id.rg_setting)
    RadioGroup mRgSetting;
    @BindView(R.id.rb_voice)
    RadioButton mRbVoice;
    @BindView(R.id.rb_basic_configuration)
    RadioButton mRbBasicConfiguration;
    @BindView(R.id.rb_help)
    RadioButton mRbHelp;

    public SettingActivity() {
        super(R.layout.activity_setting);
    }

    @Override
    protected void initView() {

        if (TextUtils.isEmpty(SPUtils.getInstance().getString("service_address"))) {
            mRbBasicConfiguration.setChecked(true);
            addFragment(R.id.fl_content, new BasicConfigurationFragment());
        } else {
            mRbOperate.setChecked(true);
            addFragment(R.id.fl_content, new OperateFragment());
        }
        mRgSetting.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rb_operate://操作模式
                        replaceFragment(R.id.fl_content, new OperateFragment());
                        break;
                    case R.id.rb_voice://语音呼叫
                        replaceFragment(R.id.fl_content, new VoiceFragment());
                        break;
                    case R.id.rb_basic_configuration://基础配置
                        replaceFragment(R.id.fl_content, new BasicConfigurationFragment());
                        break;
                    case R.id.rb_type://品类
                        replaceFragment(R.id.fl_content,new TypeFragment());
                        break;
                    case R.id.rb_help://关于
                        replaceFragment(R.id.fl_content, new HelpFragment());
                        break;
                }
            }
        });
    }

    @OnClick({R.id.iv_cancel})
    void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_cancel:
                finish();
                break;
        }
    }

}
